﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common.Model;
using BLL;
namespace stock.GuPiao
{
    public partial class Login1 : System.Web.UI.Page
    {
        CustomerBLL BL = new CustomerBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] != null)
            {
                Server.Transfer("user.aspx");
                return;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Session["id"] != null)
            {
                Server.Transfer("user.aspx");
                return;
            }
            String name = tbName.Text.Trim();
            String pwd = tbPwd.Text.Trim();
            string script;
            pwd = DESEncrypt.Encrypt(pwd);
            int loginOK = BL.Login(name, pwd);
            if (loginOK>0)
            {
                 
                Session["id"] =loginOK;
                Response.Redirect("User.aspx");
                return;
            }
            else
            {
                script = "<script language='Javascript'>alert('用户名或者密码错误！');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", script);
                return;
            }
        }
    }
}